package cn.thoughtworks.school.programCenter.feign;

import cn.thoughtworks.school.programCenter.entities.commands.CreateQuizSuggestion;
import cn.thoughtworks.school.programCenter.entities.dto.AssignmentQuizData;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

import java.net.CacheRequest;
import java.util.List;
import java.util.Map;


@FeignClient(name = "${feign.quizCenter.name}",
  url = "${feign.quizCenter.url}")
@Service
public interface QuizCenterFeign {

    @GetMapping("api/v3/basicQuizzes/selecting/{ids}")
    ResponseEntity<List> getBasicQuizzes(@PathVariable("ids") String ids);

    @GetMapping("api/v3/subjectiveQuizzes/selecting/{ids}")
    ResponseEntity<List> getSubjectiveQuizzes(@PathVariable("ids") String ids);

    @GetMapping("api/v3/logicQuizzes/selecting/{ids}")
    ResponseEntity<List> getLogicQuizzes(@PathVariable("ids") String ids);

    @GetMapping("api/v3/homeworkQuizzes/{ids}")
    ResponseEntity<List> getHomeworkQuizzesByIds(@PathVariable("ids") String ids,
                                                 @RequestParam("status") String status);

    @GetMapping("api/v3/onlineCodingQuizzes/{ids}")
    ResponseEntity<List> getOnlineCodingQuizzesByIds(@PathVariable("ids") String ids,
                                                     @RequestParam("status") String status);

    @GetMapping("api/v3/onlineLanguageQuizzes/{ids}")
    ResponseEntity<List> getOnlineLanguageQuizzesByIds(@PathVariable("ids") String ids,
                                                       @RequestParam("status") String status);

    @GetMapping("api/v3/homeworkQuizzes/students/{studentId}/assignments/{assignmentId}/quizzes/{ids}")
    ResponseEntity<List> getHomeworkWithUserAnswer(@PathVariable("studentId") Long studentId,
                                                   @PathVariable("assignmentId") Long assignmentId,
                                                   @PathVariable("ids") String ids);

    @GetMapping("api/v3/onlineCodingQuizzes/students/{studentId}/assignments/{assignmentId}/quizzes/{ids}")
    ResponseEntity<List> getOnlineCodingQuizzesWithUserAnswer(@PathVariable("studentId") Long studentId,
                                                              @PathVariable("assignmentId") Long assignmentId,
                                                              @PathVariable("ids") String ids);

    @GetMapping("api/v3/onlineLanguageQuizzes/students/{studentId}/assignments/{assignmentId}/quizzes/{ids}")
    ResponseEntity<List> getOnlineLanguageQuizzesWithUserAnswer(@PathVariable("studentId") Long studentId,
                                                                @PathVariable("assignmentId") Long assignmentId,
                                                                @PathVariable("ids") String ids);

    @GetMapping("api/v3/subjectiveQuizzes/students/{studentId}/assignments/{assignmentId}/quizzes/{ids}")
    ResponseEntity<List> getSubjectiveQuizzesWithUserAnswer(@PathVariable("studentId") Long studentId,
                                                            @PathVariable("assignmentId") Long assignmentId,
                                                            @PathVariable("ids") String ids);

    @GetMapping("api/simpleCodingQuizzes/students/{studentId}/assignments/{assignmentId}/quizzes/{ids}")
    ResponseEntity<List> getSimpleCodingQuizzesWithUserAnswer(@PathVariable("studentId") Long studentId,
                                                              @PathVariable("assignmentId") Long assignmentId,
                                                              @PathVariable("ids") String ids);

    @PostMapping("api/simpleCodingSubmissions")
    ResponseEntity<Map> createSimpleCodingSubmission(@RequestBody Map data);

    @PostMapping("api/v3/subjectiveQuizzes/students/{studentId}/assignments/{assignmentId}/quizzes/{quizId}")
    ResponseEntity<Map> submitSubjectiveAnswer(@PathVariable("studentId") Long studentId,
                                               @PathVariable("assignmentId") Long assignmentId,
                                               @PathVariable("quizId") Long quizId,
                                               @RequestBody Map data);

    @PostMapping("api/single-stack-programming-quiz-submissions")
    ResponseEntity<Map> createSubmission(@RequestBody Map data);

    @PostMapping("api/v3/onlineCodingSubmission")
    ResponseEntity<Map> judgeOnlineCodingQuiz(@RequestBody Map data);

    @PostMapping("api/single-language-online-coding-submissions")
    ResponseEntity<Map> addSubmission(@RequestBody Map data);

    @GetMapping("api/v3/homeworkSubmission/{id}/logs")
    ResponseEntity<Map> getSubmissionHomeworkLogBySubmissionId(@PathVariable("id") Long id);

    @GetMapping("api/v3/homeworkSubmission/users/{userId}/assignments/{assignmentId}/quizzess/{quizId}/logs")
    ResponseEntity<Map> getSubmissionHomeworkLogBySubmissionId(@PathVariable("assignmentId") Long assignmentId,
                                                               @PathVariable("quizId") Long quizId,
                                                               @PathVariable("userId") Long userId);

    @GetMapping("api/v3/onlineCodingSubmission/users/{id}/logs")
    ResponseEntity<Map> getSubmissionOnlineCodingLogBySubmissionId(@PathVariable("id") Long id);

    @GetMapping("api/v3/onlineCodingSubmission/users/{userId}/assignments/{assignmentId}/quizzess/{quizId}/logs")
    ResponseEntity<Map> getSubmissionOnlineCodingLogBySubmissionId(@PathVariable("assignmentId") Long assignmentId,
                                                                   @PathVariable("quizId") Long quizId,
                                                                   @PathVariable("userId") Long userId);

    //    @GetMapping("api/v3/onlineLanguageSubmission/users/{id}/logs")
    @GetMapping("api/single-language-online-coding-submissions/{id}")
    ResponseEntity<Map> getSubmissionOnlineLanguageLogBySubmissionId(@PathVariable("id") Long id);

    @GetMapping("api/v3/onlineLanguageSubmission/users/{userId}/assignments/{assignmentId}/quizzess/{quizId}/logs")
    ResponseEntity<Map> getSubmissionOnlineLanguageLogBySubmissionId(@PathVariable("assignmentId") Long assignmentId,
                                                                     @PathVariable("quizId") Long quizId,
                                                                     @PathVariable("userId") Long userId);

    @PostMapping("api/v3/basicQuizzes/students/{studentId}/assignments/{assignmentId}/quizzes")
    ResponseEntity<List> submitBasicQuiz(@PathVariable("studentId") Long studentId,
                                         @PathVariable("assignmentId") Long assignmentId,
                                         @RequestBody List<Map> data);

    @GetMapping("api/v3/basicQuizzes/students/{studentId}/assignments/{assignmentId}/quizzes/{ids}")
    ResponseEntity<List> getBasicQuizList(@PathVariable("studentId") Long studentId,
                                          @PathVariable("assignmentId") Long assignmentId,
                                          @PathVariable("ids") String ids);

    @GetMapping("api/v3/homeworkQuizzes/{ids}")
    ResponseEntity<Map> getCoding(@PathVariable("ids") String ids,
                                  @RequestParam(value = "status", defaultValue = "") String status);

    @GetMapping("api/v3/onlineCodingQuizzes/{ids}")
    ResponseEntity<Map> getOnlineCoding(@PathVariable("ids") String ids,
                                        @RequestParam(value = "status", defaultValue = "") String status);

    @GetMapping("api/v3/onlineLanguageQuizzes/{ids}")
    ResponseEntity<Map> getOnlineLanguageCoding(@PathVariable("ids") String ids,
                                                @RequestParam(value = "status", defaultValue = "") String status);

    @GetMapping("api/v3/homeworkQuizzes/{quizId}/answerFile")
    void downloadHomeworkAnswerFile(@PathVariable("quizId") Long quizId);

    @GetMapping("api/v3/onlineCodingQuizzes/{id}/answerFile")
    ResponseEntity<String> getOnlineCodingQuizzes(@PathVariable("id") Long id);

    @GetMapping("api/v3/onlineLanguageQuizzes/{quizId}/answerFile")
    ResponseEntity<String> getOnlineLanguageQuizzes(@PathVariable("quizId") Long quizId);

    @GetMapping("api/v3/homeworkSubmission//oldAssignments/{oldAssignmentId}/quizzes/{quizId}/newAssignments/{newAssignmentId}")
    ResponseEntity homeworkDataMigration(@PathVariable("oldAssignmentId") Long oldAssignmentId,
                                         @PathVariable("quizId") Long quizId,
                                         @PathVariable("newAssignmentId") Long newAssignmentId);

    @GetMapping("api/v3/subjectiveQuizzes/oldAssignments/{oldAssignmentId}/quizzes/{quizId}/newAssignments/{newAssignmentId}")
    ResponseEntity subjectiveQuizDataMigration(@PathVariable("oldAssignmentId") Long oldAssignmentId,
                                               @PathVariable("quizId") Long quizId,
                                               @PathVariable("newAssignmentId") Long newAssignmentId);

    @GetMapping(value = "api/v3/tags/searchTags", consumes = "application/json;charset=UTF-8")
    ResponseEntity<List> getSearchTags(@RequestHeader("id") Long id);

    @GetMapping("api/simpleCodingSubmissions/users/{userId}/assignments/{assignmentId}/quizzes/{quizId}")
    ResponseEntity<Map> getSubmissionByAssignmentIdAndQuizId(@PathVariable("userId") Long userId,
                                                             @PathVariable("assignmentId") Long assignmentId,
                                                             @PathVariable("quizId") Long quizId);

    @GetMapping(value = "/api/v3/basicQuizzes/pageable")
    ResponseEntity<Map> getBasicQuizzes(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                        @RequestParam(value = "quizId", required = false) Long quizId,
                                        @RequestParam(value = "userId", required = false) Long createId,
                                        @RequestParam(value = "description", required = false) String description,
                                        @RequestParam(value = "tags", required = false) List<String> tags,
                                        @RequestHeader("id") Long userId);

    @GetMapping(value = "/api/v3/homeworkQuizzes/pageable")
    ResponseEntity<Map> getHomeworkQuizzes(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                           @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                           @RequestParam(value = "quizId", required = false) Long quizId,
                                           @RequestParam(value = "userId", required = false) Long createId,
                                           @RequestParam(value = "description", required = false) String description,
                                           @RequestParam(value = "tags", required = false) List<String> tags,
                                           @RequestHeader("id") Long userId);

    @GetMapping(value = "/api/simpleCodingQuizzes/pageable")
    ResponseEntity<Map> getSimpleCodingQuizzes(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                               @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                               @RequestParam(value = "quizId", required = false) Long quizId,
                                               @RequestParam(value = "userId", required = false) Long createId,
                                               @RequestParam(value = "description", required = false) String description,
                                               @RequestParam(value = "tags", required = false) List<String> tags,
                                               @RequestHeader("id") Long userId);

    @GetMapping(value = "/api/v3/onlineCodingQuizzes/pageable")
    ResponseEntity<Map> getOnlineCodingQuizzes(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                               @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                               @RequestParam(value = "quizId", required = false) Long quizId,
                                               @RequestParam(value = "userId", required = false) Long createId,
                                               @RequestParam(value = "description", required = false) String description,
                                               @RequestParam(value = "tags", required = false) List<String> tags,
                                               @RequestHeader("id") Long userId);

    @GetMapping(value = "/api/v3/onlineLanguageQuizzes/pageable")
    ResponseEntity<Map> getOnlineLanguageQuizzes(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                                 @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                                 @RequestParam(value = "quizId", required = false) Long quizId,
                                                 @RequestParam(value = "userId", required = false) Long createId,
                                                 @RequestParam(value = "description", required = false) String description,
                                                 @RequestParam(value = "tags", required = false) List<String> tags,
                                                 @RequestHeader("id") Long userId);

    @GetMapping(value = "/api/v3/subjectiveQuizzes/pageable")
    ResponseEntity<Map> getSubjectiveQuizzes(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                             @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                             @RequestParam(value = "quizId", required = false) Long quizId,
                                             @RequestParam(value = "userId", required = false) Long createId,
                                             @RequestParam(value = "description", required = false) String description,
                                             @RequestParam(value = "tags", required = false) List<String> tags,
                                             @RequestHeader("id") Long userId);

    @GetMapping(value = "/api/v3/logicQuizzes/pageable")
    ResponseEntity<Map> getAllLogicQuizzes(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                           @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                           @RequestParam(value = "quizId", required = false) Long quizId,
                                           @RequestParam(value = "userId", required = false) Long createId,
                                           @RequestParam(value = "description", required = false) String description,
                                           @RequestParam(value = "tags", required = false) List<String> tags,
                                           @RequestHeader("id") Long userId);

    @GetMapping(value = "/api/simpleCodingQuizzes/{id}")
    ResponseEntity<Map> getSimpleCodingQuizzesById(@PathVariable("id") String id);

    @GetMapping(value = "/api/tw-logic-quiz-submission/submissions")
    Map getLogicQuizSubmission(@RequestParam("assignmentId") Long assignmentId,
                                               @RequestParam("quizId") Long quizId,
                                               @RequestHeader("id") Long userId);

    @GetMapping(value = "api/tw-logic-quizzes/{id}")
    ResponseEntity<Map> getLogicQuiz(@PathVariable("id") Long quizId);


    @PostMapping(value = "/api/v3/quizzes/duplication")
    List<AssignmentQuizData> copyQuizzesToOrganization(List<AssignmentQuizData> assignmentQuizData);

    @PostMapping(value = "/api/v3/quizzes/suggestions")
    void submitQuizSuggestion(@RequestBody CreateQuizSuggestion createQuizSuggestion);

    @GetMapping(value = "/api/surveyQuizzes/pageable")
    ResponseEntity<Map> getAllSurveyQuizzes(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                        @RequestParam(value = "quizId", required = false) Long quizId,
                                        @RequestParam(value = "userId", required = false) Long createId,
                                        @RequestParam(value = "description", required = false) String description,
                                        @RequestParam(value = "tags", required = false) List<String> tags,
                                        @RequestHeader("id") Long userId);

    @GetMapping("/api/surveyQuizzes/selecting/{ids}")
    ResponseEntity<List> getSurveyQuizzes(@PathVariable("ids") String ids);

    @GetMapping("api/surveyQuizzes/students/{studentId}/assignments/{assignmentId}/quizzes/{ids}")
    ResponseEntity<List> getSurveyQuizzesSubmission(@PathVariable("studentId") Long studentId,
                                          @PathVariable("assignmentId") Long assignmentId,
                                          @PathVariable("ids") String ids);
    @PostMapping("api/surveyQuizzes/students/{studentId}/assignments/{assignmentId}/quizzes")
    ResponseEntity<List> submitSurveyQuizAnswer(@PathVariable("studentId") Long studentId,
                                         @PathVariable("assignmentId") Long assignmentId,
                                         @RequestBody List<Map> data);

    @GetMapping("api/v3/basicQuizzes/assignments/{assignmentId}/score")
    Map<Long,List<Map>> calculateBasicQuizAssignmentScore(@PathVariable("assignmentId") Long assignmentId);
}
